<template>
    <div class="singer">

        <!-- 返回主页 -->
        <div class="nav">
        <router-link to="/">
            <div class="back-icon">
                <img src="../assets/back.svg">
            </div>
        </router-link>
        <h3>歌手详情</h3>
        </div>
        <!-- 歌手页 -->
        <div class="hd">
            <img :src="this.SingerDetails.cover"  class="cover">
            <!-- <router-link to="/">
                <div class="back-icon">
                    <img src="../assets/back.svg">
                </div>
            </router-link> -->
            <div class="artist-info" v-if="this.SingerDetails.rank&&this.SingerDetails.rank.rank">
                <p class="name">{{this.SingerDetails.name}}</p>
                <p class="rank">歌手榜华语地区 No.{{this.SingerDetails.rank.rank}}</p>
                <div class="simple">
                    <span class="funs-count">粉丝数</span>
                </div>
            </div>
        </div>

        <!-- 歌手简介 -->
        <h2>歌手简介</h2>
        <div class="intro">
            <p style="color:#666" :class="{thide:thideChange}">{{this.SingerDetails.briefDesc}}</p>
            <div class="full" @click="thidechange">
                {{thideChange?"完整歌手介绍":"收起"}}
                <i  :class="thideChange ? 'arrow' : 'arrow arrow-up'"></i>
            </div>
        </div>

        <!-- 歌手的热门单曲 -->
        <span>
            <h2>热门单曲</h2>
            <song-item :item="SingerSongs" :playnumber="true" @play="$emit('play',$event)"></song-item>
        </span>

        <router-view></router-view>
    </div>
</template>

<script>
import SongItem from "@/components/SongItem.vue";
export default {
    props:[
        "sid"
    ],
    data(){
        return{
            SingerDetails:[],
            SingerSongs:[],
            thideChange:true,
        }
    },
    created(){
        this.getSingDetails();
        this.getSingerSongs();
    },
    methods:{
        async getSingDetails(){
            let res=await this.axios.get("/artist/detail?id="+this.sid)
            this.SingerDetails=res.artist
        },
        async getSingerSongs(){
            let res=await this.axios.get("/artist/top/song?id="+this.sid)
            let SingerSongs=res.songs
            this.SingerSongs=SingerSongs.map((song)=>{
                song.song={
                    album:song.al,
                    privilege:song.privilege,
                    artists:song.ar,
                    alias:song.alia, 
                }
                return song
            })
        },
        thidechange(){
            this.thideChange=!this.thideChange
        }
    },
    components:{
        SongItem,
    }
}
</script>

<style lang="less" scoped>
.singer{
    position: sticky;
    top: 0px;
    left: 0px;
    z-index: 10;
    width: 100%;
    margin-top: 40px;
    margin-bottom: 60px;
    .nav{
        position: fixed;
        /* position: absolute; */
        top: 0px;
        width: 100%;
        height: 40px;
        display: flex;
        align-items: center;
        /* color: #fff; */
        background: white;
        z-index: 3;
        h3{
        height: 20px;
        line-height: 20px;
        padding-left: 10px;
        }
        .back-icon{
            padding-left: 10px;
            width: 20px;
            height: 20px;
            &>img{
                width: 20px;
            }
        }
    }
    h2{
        font-size: 18px;
        font-weight: 700;
        position: relative;
        margin-top: -5px;
        padding: 15px;
        background: #fff;
        z-index: 2;
    }
    .hd{
        position:relative;
        padding-top: 82.9%;
        .cover{
            width: 100%;
            position: absolute;
            top: 0px;
        }
        .artist-info{
            position: absolute;
            bottom: 30px;
            left: 16px;
            color: #fff;
            z-index: 2;
            .name{
                font-size: 20px;
                line-height: 20px;
            }
            .rank{
                margin-top: 15px;
                font-style: 13px;
            }
            .simple{
                margin-top: 15px;
                opacity: .8;
                font-size: 12px;
                line-height: 12px;
            }
        }
        // .back-icon{
        //     position: absolute;
        //     top: 10px;
        //     left: 10px;
        //     width: 30px;
        //     height: 30px;
        //     &>img{
        //         width: 30px;
        //     }
        // }
    }
    .intro{
        background: #fff;
        padding: 0px 16px 18px;
        .thide{
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-line-clamp: 3;
            -webkit-box-orient: vertical;
        }
    }
    .full{
        font-size: 14px;
        color: #666;
        text-align: center;
        margin-top: 25px;
        margin-bottom: 8px;
        .arrow{
            display: inline-block;
            background: url("../assets/arrow.png") no-repeat ;
            background-size: contain;
            width: 12px;
            height: 12px;
            
            position: relative;
            left: 4px;
            top: 0px;
        }
        .arrow-up{
            width: 12px;
            height: 12px;
            top: 2px;
            transform: rotate(180deg);
        }
    } 
}
</style>